<template>
  <!--  <h2>档案征集</h2>-->
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="4" :xs="24">
        <fileTrees @handleNodeClick="onTreeClick" :tableHeight="treeHeight" :isnoClick="isnoClick" :menuId="menuId">
        </fileTrees>
      </el-col>
      <el-col :span="20" :xs="24" v-show="isShow">
        <queryCriteriaList v-if="listFrom.length > 0" :showSearch="showSearch" :listFrom="listFrom"
          @resetQuery="resetQuery" @handleQuery="handleQuery" ref="queryForm"></queryCriteriaList>
        <el-row :gutter="10" class="mb8" ref="refbut">
          <el-col :span="1.5"
            v-show="(subStr == 'F' && categoryType == 0) || (subStr == 'V' && categoryType == 1) || (subStr == 'X' && categoryType == 3)">
            <el-button type="primary" plain icon="el-icon-takeaway-box" v-hasPermi="['archive:dazj:jieshou']"
              @click="handleJieshouTap()">接收</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="primary" plain icon="el-icon-plus" v-show="(subStr == 'X' && categoryType == 3)"
              @click="handledeitTap(0)" v-hasPermi="['archive:dazj:addItem']">项目著录</el-button>
            <!--案卷著录-->
            <el-button type="primary" plain icon="el-icon-plus" v-show="(subStr == 'V' && categoryType == 1)"
              @click="handledeitTap(0)" v-hasPermi="['archive:dazj:addFolder']">著录</el-button>
            <!--件著录-->
            <el-button type="primary" plain icon="el-icon-plus" v-show="(subStr == 'F' && categoryType == 0)"
              @click="handledeitTap(0)" v-hasPermi="['archive:dazj:addYqda']">著录</el-button>
          </el-col>
          <el-col :span="1.5" v-show="subStr == 'X'">
            <el-button type="primary" plain icon="el-icon-printer" @click="handledeitanJuanTap()"
              v-hasPermi="['archive:dazj:addAnJuan']">案卷著录</el-button>
          </el-col>

          <el-col :span="1.5" v-show="subStr == 'X'">
            <el-button type="primary" plain icon="el-icon-printer" @click="handledeitanDeitJuanTap()"
              v-hasPermi="['archive:dazj:updateAnJuan']">案卷修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <!--项目修改-->
            <el-button type="success" plain icon="el-icon-edit" v-show="(subStr == 'X')" @click="handledeitTap(1)"
              v-hasPermi="['archive:dazj:updateItem']">修改</el-button>
            <!--案卷修改-->
            <el-button type="success" plain icon="el-icon-edit" v-show="(subStr == 'V')" @click="handledeitTap(1)"
              v-hasPermi="['archive:dazj:updateFolder']">修改</el-button>
            <!--件修改-->
            <el-button type="success" plain icon="el-icon-edit" v-show="(subStr == 'F')" @click="handledeitTap(1)"
              v-hasPermi="['archive:dazj:updateYqda']">修改</el-button>

          </el-col>
          <el-col :span="1.5">
            <!--项目删除-->
            <el-button type="danger" plain icon="el-icon-delete" v-show="(subStr == 'X')" @click="handleDeleteTap()"
              v-hasPermi="['archive:dazj:deleteItem']">删除</el-button>
            <!--案卷删除-->
            <el-button type="danger" plain icon="el-icon-delete" v-show="(subStr == 'V')" @click="handleDeleteTap()"
              v-hasPermi="['archive:dazj:deleteFolder']">删除</el-button>
            <!--件删除-->
            <el-button type="danger" plain icon="el-icon-delete" v-show="(subStr == 'F')" @click="handleDeleteTap()"
              v-hasPermi="['archive:dazj:deleteYqda']">删除</el-button>
          </el-col>

          <el-col :span="1.5">
                        <!--  @click="handleImport" -->
                        <!--件导入-->
                        <el-button type="primary" plain icon="el-icon-upload2" v-show="subStr == 'F'" @click="handleImport"
                            v-hasPermi="['archive:wjzl:daoru1']">导入</el-button>
                        <!--项目导入-->
                        <el-button type="primary" plain icon="el-icon-upload2" v-show="subStr == 'X'" @click="handleImport"
                            v-hasPermi="['archive:wjzl:daoru2']">导入</el-button>
                        <!--项目层的案卷导入-->
                        <el-button type="primary" plain icon="el-icon-upload2" v-show="subStr == 'X'"
                            @click="handleImportFolder" v-hasPermi="['archive:wjzl:anjuandaoru1']">案卷导入</el-button>
                        <!--案卷层的案卷导入-->
                        <el-button type="primary" plain icon="el-icon-upload2" v-show="subStr == 'V'"
                            @click="handleImportFolder" v-hasPermi="['archive:wjzl:anjuandaoru2']">案卷导入</el-button>
                    </el-col>
                    <el-col :span="1.5" v-show="subStr == 'V'">
                        <el-button type="primary" plain icon="el-icon-printer" @click="handleImportFile()"
                            v-hasPermi="['archive:wjzl:juanneijiandaoru']">卷内件导入</el-button>
                    </el-col>
          <!--
          <el-col :span="1.5" v-show="subStr == 'F' && (categoryType == 1 || categoryType == 3)">

            <el-button type="primary" icon="el-icon-files" @click="mergeYqdaTap(1)">组卷</el-button>
          </el-col>
          <el-col :span="1.5"
                  v-show="(subStr == 'F' && categoryType == 0) || (subStr == 'V' && categoryType == 1) || (subStr == 'X' && categoryType == 3)">
            <el-button type="primary" plain icon="el-icon-folder-add">移入资料库</el-button>
          </el-col>
         -->
        </el-row>
        <tableList v-if="tableHeight" :tableHeaderList="tableHeaderList" @handleSelectionChange="handleSelectionChange"
          :tableData="tableData" :loading="loading" :tableHeight="tableHeight" @celldblclick="celldblclick"
          @sortChange="sortChange" ref="ref"></tableList>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getlistPost" />
      </el-col>

      <el-col :span="20" :xs="24" v-show="!isShow" class="empty">
        <el-empty :image-size="200"></el-empty>
      </el-col>
    </el-row>

    <!-- start 组件著录、修改 -->
    <jiandeit v-if="jianOpen" :open="jianOpen" :openInfo="openInfo" @closeDelDialog="closeDelDialog"
      @submitDetail="submitDetail" @submitTooDetail="submitTooDetail" :isParams="5">
    </jiandeit>
    <!-- end  组件著录、修改-->

    <!-- start 组卷著录、修改 -->
    <juandeit v-if="juanOpen" :open="juanOpen" :openInfo="openInfo" @closeDelDialog="closeDelDialog"
      @submitDetail="submitDetail" :isParams="5" :isZUXIU="isZUXIU" :isShow="isShowButton"></juandeit>
    <!-- end  组卷著录、修改-->

    <!-- start 项目著录  修改 -->
    <projectdeit v-if="projectOpen" :open="projectOpen" :openInfo="openInfo" @submitDetail="submitDetail"
      @closeDelDialog="closeDelDialog" :isParams="5"></projectdeit>
    <!-- end 项目著录、修改 -->

    <!--start  组件详情 -->
    <jianDetailsOpen v-if="jianDetailsOpen" :open="jianDetailsOpen" :celldbData="celldbData"
      @detailsHandleClose="detailsHandleClose">
    </jianDetailsOpen>
    <!--end 组件详情 -->
    <!-- start 组卷\项目详情 -->
    <juanDetailsOpen v-if="juanDetailsOpen" :open="juanDetailsOpen" :celldbData="celldbData" module="archivesCollection"
      :isParams="5" :treeRowData="treeRowData" @detailsHandleClose="detailsHandleClose"></juanDetailsOpen>
    <!-- end 组卷\项目详情 -->

    <!-- start 项目下面的卷列表修改 -->
    <projectJuanlistDeit v-if="projectJuanlistDeitOpen" :open="projectJuanlistDeitOpen" :celldbData="celldbData"
      @detailsHandleClose="detailsHandleClose" :openInfo="openInfo" :isParams="5" :isShow="isShowButton">
    </projectJuanlistDeit>
    <!-- end  项目下面的卷列表修改 -->

     <!-- 用户导入对话框 -->
     <dataImport :upload="upload" @uploadCancel="uploadCancelTap" @importTemplate="importTemplateTap"
            @uploadFile="uploadFile" @submitFileForm="submit"></dataImport>

        <!-- 导入匹配页 -->
        <importMatch :match="match" ref="matchRef" @matchCancel="matchCancelTap" @submitMatch="submitMatch"></importMatch>
  </div>
</template>

<script>
import fileTrees from "@/components/fileTrees/index.vue";//档案树
import { getLastIndexOf } from "@/utils";
import { getGroupTree } from "@/api/archive/archivesCategory";
import treeHeight from '@/mixins/treeHeight'; //计算左侧树的高度
import queryCriteriaList from "@/components/queryCriteriaList/index.vue";  //查询列表
import tableList from "@/components/tableList/index.vue";
import jianDetailsOpen from '@/components/componentsJianDetails/index.vue'; //件详情
import juanDetailsOpen from '@/components/componentsJuanDetails/index.vue'; //卷详情
import jiandeit from "@/views/archive/fileCollection/offlinReception/jiandeit.vue" //件添加修改弹窗
import juandeit from "@/views/archive/fileCollection/offlinReception/juandeit.vue" //卷添加修改弹窗
import projectdeit from "@/views/archive/fileCollection/offlinReception/projectdeit.vue" //卷添加修改弹窗
import projectJuanlistDeit from "@/views/archive/fileCollection/offlinReception/projectJuanlistDeit.vue" //项目下面的卷列表修改
import { geturl, getTitle, uploadList } from "@/api/archive/fileCollection/offlinReception";
import {
  deleteData,
  getlistbytreenodeList,
  getqueryfieldList,
  getthbytreenodeHeaderList,
} from "@/api/archive/fileCollection/offlinReception";
import { getTypeObject } from "@/api/archive/dict/dictManageData";
import { jieshou } from "@/api/archive/digitalizeReceive/archivesCollection";
import dataImport from "@/components/dataImportComponent/dataImport.vue";
import importMatch from "@/components/dataImportComponent/importMatch.vue";
// import { getRouters } from "@/api/menu.js"
export default {
  name: "index",
  components: { fileTrees, queryCriteriaList, tableList, jianDetailsOpen, juanDetailsOpen, jiandeit, juandeit, projectdeit, projectJuanlistDeit,dataImport,
        importMatch, },
  mixins: [treeHeight], // 混入方法
  data() {
    return {
      isnoClick: true, //防止树重复点击
      menuId: '',
      isShow: false, //是否显示右侧数据 isShow:true,  //判断  著录项目内件按钮是否显示
      isShowButton: true,
      listFrom: [], //查询框列表
      // 显示搜索条件
      showSearch: true,
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      tableHeight: '',
      tableHeaderList: [], //table表头数据
      tableData: [],//table列表数据
      loading: false,
      jianDetailsOpen: false,//件详情弹窗
      juanDetailsOpen: false,//卷详情弹窗
      projectJuanlistDeitOpen: false,//项目下面的卷列表修改
      treeRowData: "", //点击档案树显示当前点击数据
      celldbData: "",
      subStr: "",  //获取点击当前树的 件 卷  项目 截取 sub_table_name显示
      categoryType: "",
      jianOpen: false, //组件打开关闭
      juanOpen: false, //组卷打开关闭
      projectOpen: false,//项目打开关闭
      openInfo: { //件 卷  项目
        opens: false,
        categoryId: undefined,
        menuId: undefined,
        type: undefined
      },
      isZUXIU: "",

       // 用户导入参数
       upload: {
                // 是否显示弹出层（用户导入）
                open: false,
                // 弹出层标题（用户导入）
                title: "",
            },
            // 导入文件类型  件、卷、项目
            uploadType: null,
            // 表格表头
            xlsTitle: [],
            // 可导入项
            sysTitle: [],
            // 匹配参数
            match: {
                // 是否显示弹出层
                open: false,
                // 弹出层标题
                title: "",
            },
    }
  },
  created() {
    this.menuId = this.$route.meta.menuId
  },
  methods: {
    //动态设置table的高度
    tableHeightData() {
      this.$nextTick(
        () => {
          let h = document.documentElement.clientHeight
          //     console.log(this.$refs.queryForm.$el.offsetHeight, this.$refs.refbut.$el.offsetHeight, "sdklfjklliuhaiorng")
          h = h - 200
          if (this.$refs.queryForm) { // 页面上如果有面包屑区域徐减去它的高度
            h = h - this.$refs.queryForm.$el.offsetHeight
          }

          if (this.$refs.refbut) { // 页面上如果有分页区域徐减去它的高度
            h = h - this.$refs.refbut.$el.offsetHeight
          }
          // console.log(h,"sdjfdklsjfkl")
          this.tableHeight = h > 310 ? h : 310 // 根据自己项目定高度

          return h
        }
      )

    },
    // 树节点单击事件
    onTreeClick(data) {
      this.isnoClick = false;
      this.treeRowData = data;

      if (data.categoryId != null) {
        this.isShow = true
      } else {
        this.isShow = false
      }
      if (this.$refs.queryForm != undefined) {
        this.$refs.queryForm.queryParams = {};
      }
      if (data.nodeType == null || data.nodeType == "t" || data.nodeType == "f") {
        this.isnoClick = true;
        return false;
      }
      this.loading = true;
      this.queryParams = data;
      this.queryParams.order = '';
      this.queryParams.state = 11;
      this.queryParams.jsType = 3;
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 10;
      if (this.queryParams.sub_table_name != undefined) {
        this.subStr = getLastIndexOf(this.queryParams.sub_table_name);
        let stb = this.queryParams.sub_table_name;
        let stbArr = stb.split("_");
        this.categoryType = stbArr[stbArr.length - 3];
      } else {
        this.getGroupTreePost(data.categoryId);
      }
      this.getqueryfieldListPost();//点击树节点获取查询字段
      this.getlistHeaderPost();/**点击树节点,获取table表头数据 */
      if (this.$refs.ref) {
        this.$refs.ref.clearSort()
      }
    },
    //档案门类树门类根据categoryID回显
    getGroupTreePost(ID) {
      getGroupTree(ID).then(response => {
        this.responselist = response.data;
        if (response.data.type == "0") { //件
          this.queryParams.sub_table_name = response.data.fileTableName;
        } else if (response.data.type == "1") { //卷
          this.queryParams.sub_table_name = response.data.folderTableName;
        } else { //项目
          this.queryParams.sub_table_name = response.data.itemTableName;
        }
        this.subStr = getLastIndexOf(this.queryParams.sub_table_name);
        let stb = this.queryParams.sub_table_name;
        let stbArr = stb.split("_");
        this.categoryType = stbArr[stbArr.length - 3];
      });
    },
    /** 点击树节点获取查询字段 */
    getqueryfieldListPost(data) {
      getqueryfieldList({
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        subTableName: this.queryParams.sub_table_name,

      }).then(response => {
        this.listFrom = response.rows;
      });
    },
    /**点击树节点,获取table表头数据 */
    getlistHeaderPost() {
      getthbytreenodeHeaderList({
        categoryId: this.queryParams.categoryId, menuId: this.queryParams.menuId, subTableName: this.queryParams.sub_table_name
      }
      ).then(response => {
        this.tableHeaderList = response.rows;
        var fields = []
        for (var i in response.rows) {
          fields.push(response.rows[i].FIELD_NAME)
        }
        this.queryParams.fields = fields.toString()
        //获取指定字典列表
        var headerlist = [];
        for (var i = 0; i < this.tableHeaderList.length; i++) {
          if (this.tableHeaderList[i].SHOWTYPE.toString().indexOf('5') != -1) {
            this.tableHeaderList[i].SHOWTYPE = 5
          }
          if (this.tableHeaderList[i].SHOWTYPE == 5) {
            // console.log(this.tableHeaderList[i])
            headerlist.push(this.tableHeaderList[i].FIELD_NAME)
          }
        }
        // console.log(headerlist,"++++")
        if (headerlist.length > 0) {
          getTypeObject(headerlist).then((res) => {
            this.dictList = res.data;
          })
        }
        this.getlistPost();
      });
    },
    //表单重置
    resetQuery() {
      this.queryParams.searchcolumn = undefined
      this.queryParams.order = undefined;
      this.getlistPost();
      this.$refs.ref.clearSort()   //情况排序样式
    },
    //点击搜索
    handleQuery(searchcolumn) {
      var column = searchcolumn.filter(item => { return item.value !== '' && item.value !== null })
      this.queryParams.searchcolumn = column
      this.queryParams.order = undefined;
      this.getlistPost();
      this.$refs.ref.clearSort()
    },
    /** 点击树节点,获取table数据*/
    getlistPost() {
      var that = this;
      this.loading = true;
      getlistbytreenodeList(this.queryParams).then(response => {
        this.tableData = response.rows;
        this.total = response.total;
        this.loading = false;
        this.tableHeightData();
        this.isnoClick = true;
      });
    },
    //关闭著录 \件\ 组卷\目录打印
    closeDelDialog() {
      this.jianOpen = false //件
      this.juanOpen = false //卷
      this.projectOpen = false; //项目
      this.printOpen = false;//目录打印
      this.openInfo = "";
      this.getlistHeaderPost();
    },
    //继承追加成功
    submitTooDetail() {
      this.getlistHeaderPost();
    },
    //著录成功
    submitDetail() {
      this.jianOpen = false;
      this.juanOpen = false //卷
      this.projectOpen = false; //项目
      this.getlistHeaderPost();
    },
    //是否选择数据
    handleSelectionChange(ids, single, multiple) {
      this.ids = ids.toString();
      this.single = single;
      this.multiple = multiple;
    },
    //双击列表进入详情页面
    celldblclick(row) {
      var level = "";
      var label = "";
      if (getLastIndexOf(this.queryParams.sub_table_name) == "F") {  //F 件
        level = 0
        label = row.TITLE;
      } else if (getLastIndexOf(this.queryParams.sub_table_name) == "V") { //卷
        level = 1
        label = row.TITLE;
      } else { //项目
        level = 3
        label = row.XMMC;
      }

      this.celldbData = {
        id: row.ID,
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        sub_table_name: this.queryParams.sub_table_name,
        label: label,
        level: level,
        ifSub_table_name: this.queryParams.sub_table_name,
        isDel: "0",  //判断是回收站数据还是接收收据 isDel:1  回收站    isDel:0 //离线接收、档案接收、在线接收
        tableHeaderList: this.tableHeaderList
      }
      this.$nextTick(() => {
        if (this.subStr == "F") {  //F 进入件详情
          this.jianDetailsOpen = true;
        } else { //进入卷详情 和项目详情
          this.juanDetailsOpen = true
        }
      })

    },
    //关闭详情页面
    detailsHandleClose() {
      this.jianDetailsOpen = false;
      this.juanDetailsOpen = false;
      this.projectJuanlistDeitOpen = false;
    },
    //排序
    sortChange(val) {
      this.queryParams.order = val;
      this.getlistPost();
    },
    //件  this.jianOpen  著录和修改     //组卷 this.juanOpen 著录和修改    //项目 this.projectdOpen 著录和修改
    handledeitTap(e) {
      // console.log
      this.openInfo = {
        opens: true,
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        folderId: undefined, //组卷id
        itemId: undefined, //项目Id
        subTableName: this.queryParams.sub_table_name,
        nodeType: this.queryParams.nodeType,
        parentNodeType: this.queryParams.parentNodeType,
        parentSubTableName: this.queryParams.parentSubTableName,
        subStr: this.subStr,
      }
      // console.log(this.openInfo)
      if (e == 1) {  //修改
        if (this.ids == undefined) {
          this.$message({ message: '请选择要修改的数据哦', type: 'warning' })
          return false
        }
        if (this.single) {
          this.$message({ message: '请选择一条要修改的数据哦', type: 'warning' })
          return false
        }
        this.openInfo.ids = this.ids; //组件Id;
      } else { //添加
        this.openInfo.ids = undefined
      }
      if (this.subStr == "F") {  //F 件
        this.openInfo.type = 0
        this.jianOpen = true
      } else if (this.subStr == "V") { //卷
        this.openInfo.type = 1
        this.juanOpen = true;
      } else { //项目
        this.openInfo.type = 3
        this.projectOpen = true;
      }
    },

    //删除
    handleDeleteTap() {
      if (this.ids != undefined && !this.multiple) {
        this.$modal.confirm('是否确认删除所选数据项？').then(function () {
        }).then(() => {
          let type = "";
          if (this.subStr == "F") {  //F 件
            type = 0;
          } else if (this.subStr == "V") { //卷
            type = 1;
          } else { //项目
            type = 3;
          }
          deleteData({
            type: type,
            categoryId: this.queryParams.categoryId,
            ids: this.ids
          }).then((res) => {
            if (res.code == "200") {
              this.getlistPost();
              this.$modal.msgSuccess("删除成功");
            }
          })
        }).catch(() => { });
      } else {
        this.$message({ message: '请选择要删除的数据哦', type: 'warning' })
      }
    },

    //接收
    handleJieshouTap() {




      if (this.ids != undefined && !this.multiple) {
        this.$modal.confirm('是否确认接收所选数据数据项？').then(function () {
        }).then(() => {
          jieshou({
            categoryId: this.queryParams.categoryId,
            ids: this.ids
          }).then(res => {
            this.getlistPost();
            this.$modal.msgSuccess("接收成功");
            // 跳转文件整理 有就跳转无就不跳转
            // if(this.hasRoute("receivieManagement")){
            //   setTimeout(res => {
            //     this.$router.push({ path: "/digitalizeReceive/receivieManagement" })
            //   }, 1000)
            // }
          })
        }).catch(() => { });
      } else {
        this.$message({ message: '请选择要接收的数据哦', type: 'warning' })
      }
    },
    hasRoute(path, routeList) {
      console.log(this.routeList, "klsdfjklsdfjklsdjfkdlsfjkdsfjklsdjfkl")
      !routeList && (routeList = this.routeList, console.log('执行'))
      console.log(routeList)
      for (let i = 0; i < routeList.length; i++) {
        console.log(routeList[i].path)
        if (routeList[i].path == path) {
          return true
        }
        if (routeList[i].children) {
          let flag = this.hasRoute(path, routeList[i].children)
          if (flag) {
            return flag
          }
        }
      }
      return false
    },
    //给项目案卷著录
    handledeitanJuanTap() {
      this.isZUXIU = "1" //判断项目下的案卷是著录还是修改
      if (this.ids == undefined) {
        this.$message({ message: '请选择先选择数据哦', type: 'warning' })
        return false
      }
      if (this.single) {
        this.$message({ message: '请选择一条数据哦', type: 'warning' })
        return false
      }
      var row = this.tableData.filter(item => { return this.ids == item.ID })
      this.openInfo = {
        opens: true,
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        type: 1, //传卷类型  0,组件 1，组卷 3，项目
        folderId: undefined, //组卷id
        itemId: this.ids, //项目Id
        subTableName: this.queryParams.sub_table_name,
        subStr: this.subStr,
        label: row[0].XMMC
      }
      this.openInfo.itemId = this.ids; //项目Id;
      this.juanOpen = true;
    },
    //修改项目下面的案卷
    handledeitanDeitJuanTap() {
      var that = this;
      this.isZUXIU = "2" //判断项目下的案卷是著录还是修改
      if (this.ids == undefined) {
        this.$message({ message: '请选择先选择数据哦', type: 'warning' })
        return false
      }
      if (this.single) {
        this.$message({ message: '请选择一条数据哦', type: 'warning' })
        return false
      }
      var row = this.tableData.filter(item => { return this.ids == item.ID })
      var level = "";
      if (getLastIndexOf(this.queryParams.sub_table_name) == "F") {  //F 件
        level = 0
      } else if (getLastIndexOf(this.queryParams.sub_table_name) == "V") { //卷
        level = 1
      } else { //项目
        level = 3
      }
      this.openInfo = {
        opens: true,
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        folderId: undefined, //组卷id
        itemId: this.ids, //项目Id
        subTableName: this.responselist.fileTableName,
        nodeType: "l",
        subStr: "V",
        type: 1
      }
      this.celldbData = {
        id: row[0].ID,
        categoryId: this.queryParams.categoryId,
        menuId: this.queryParams.menuId,
        sub_table_name: this.queryParams.sub_table_name,
        label: row[0].XMMC,
        level: level,
        ifSub_table_name: this.queryParams.sub_table_name,
        isDel: "0",  //判断是回收站数据还是接收收据 isDel:1  回收站    isDel:0 //离线接收、档案接收、在线接收
      }
      that.projectJuanlistDeitOpen = true
    },
    //组卷 合并卷
    mergeYqdaTap(val) {
      if (this.ids != undefined && !this.multiple) {
        if (val == 1) {
          var IDS = this.ids.split(",")
          var datas = [];
          for (var i in this.tableData) {
            for (var j in IDS) {
              if (this.tableData[i].ID == IDS[j]) {
                if (this.tableData[i].IS_ZUJUAN == 1) {
                  datas.push(this.tableData[i].TITLE)
                }
              }
            }
          }
          if (datas.length > 0) {
            this.$message({ message: '选择的数据已经组卷', type: 'warning' })
            return
          }
          this.openInfo = {
            opens: true,
            categoryId: this.queryParams.categoryId,
            menuId: this.queryParams.menuId,
            folderId: undefined, //组卷id
            itemId: undefined, //项目Id
            subTableName: this.queryParams.sub_table_name,
            nodeType: this.queryParams.nodeType,
            parentNodeType: this.queryParams.parentNodeType,
            parentSubTableName: this.queryParams.parentSubTableName,
            subStr: this.subStr,
            type: 1,
            ids: this.ids,
            isDisabled: val //判断如果从组卷按钮和合并卷按钮进去带参isDisabled，只可以将件组成卷或者将多个卷里面的件合并，不可以在里面添加件
          }

          this.juanOpen = true;
        } else {
          // assemblyFolderVerify({
          //   categoryId: this.queryParams.categoryId,
          //   folderIds: this.ids
          // }).then(res => {
          //   this.openInfo = {
          //     opens: true,
          //     categoryId: this.queryParams.categoryId,
          //     menuId: this.queryParams.menuId,
          //     folderId: undefined, //组卷id
          //     itemId: undefined, //项目Id
          //     subTableName: this.queryParams.sub_table_name,
          //     nodeType: this.queryParams.nodeType,
          //     parentNodeType: this.queryParams.parentNodeType,
          //     parentSubTableName: this.queryParams.parentSubTableName,
          //     subStr: this.subStr,
          //     type: 1,
          //     ids: this.ids,
          //     isDisabled: val //判断如果从组卷按钮和合并卷按钮进去带参isDisabled，只可以将件组成卷或者将多个卷里面的件合并，不可以在里面添加件
          //   }
          //
          //   this.juanOpen = true;
          // }).catch(res => {
          //   // this.$message({ message:res.msg, type: 'warning' })
          // })
        }



      } else {
        this.$message({ message: '请选择要操作的数据哦', type: 'warning' })
      }
    },

            // 导入按钮  组件/项目
            handleImport() {
            if (this.subStr == "F") {
                // console.log("件导入")
                this.upload.title = "卷内件数据";
                this.upload.open = true;
                this.uploadType = 0
            } else {
                // console.log("项目导入")
                this.upload.title = "项目数据";
                this.upload.open = true;
                this.uploadType = 3
            }
        },
        // 案卷导入
        handleImportFolder() {
            if (this.subStr == 'X') {
                if (this.ids == undefined) {
                    this.$message({ message: '请选择先选择数据哦', type: 'warning' })
                    return false
                }
                if (this.single) {
                    this.$message({ message: '请选择一条数据哦', type: 'warning' })
                    return false
                }
            }
            // console.log("案卷导入")
            this.upload.title = "案卷数据";
            this.upload.open = true;
            this.uploadType = 1
        },
        //给组卷 卷内件导入
        handleImportFile() {
            if (this.ids == undefined) {
                this.$message({ message: '请选择先选择数据哦', type: 'warning' })
                return false
            }
            if (this.single) {
                this.$message({ message: '请选择一条数据哦', type: 'warning' })
                return false
            }
            // console.log("件导入")
            this.upload.title = "卷内件数据";
            this.upload.open = true;
            this.uploadType = 0
        },
        // 关闭导入  /件/卷/项目
        uploadCancelTap() {
            this.upload.open = false;
            this.getlistHeaderPost();
        },
        // 下载模板
        importTemplateTap() {
            this.form = {
                type: this.uploadType,
                categoryId: this.queryParams.categoryId
            }
            if (this.uploadType == 0) {
                // console.log("卷内件下载模板")
                this.download('/archive/daImport/download?type=' + this.uploadType + "&categoryId=" + this.queryParams.categoryId, {
                }, `fileData_template_${new Date().getTime()}.xlsx`)
            } else if (this.uploadType == 1) {
                // console.log("案卷下载模板")
                this.download('/archive/daImport/download?type=' + this.uploadType + "&categoryId=" + this.queryParams.categoryId, {
                }, `folderData_template_${new Date().getTime()}.xlsx`)
            } else {
                // console.log("项目下载模板")
                this.download('/archive/daImport/download?type=' + this.uploadType + "&categoryId=" + this.queryParams.categoryId, {
                }, `itemData_template_${new Date().getTime()}.xlsx`)
            }
        },
        // 上传文件
        uploadFile(concent) {
            this.file = concent.file
            const formData = new FormData();
            formData.append("file", concent.file);
            formData.append("categoryId", this.queryParams.categoryId);
            formData.append("type", this.uploadType);
            getTitle(formData).then(response => {
                this.xlsTitle = response.data.xlsTitle.map(item => {
                    return {
                        xlsNum: item.num,
                        xlsName: item.name
                    }
                })
                this.sysTitle = response.data.sysTitle.map(item => {
                    return {
                        name: item.fieldName,
                        caption: item.fieldCaption,
                        showType: item.showType,
                        dataLength: item.dataLength,
                        isNoEmpty: item.isNoEmpty,
                        defaultValue: item.defaultValue,
                        checkChongfu: item.checkChongfu
                    }
                })
                this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
                    console.log( this.$refs.matchRef,"------------------------")
                    this.$refs.matchRef.init(this.xlsTitle, this.sysTitle);     //获取子组件中init方法并将父组件数据传递给子组件
                });
            })
        },

        // 点击确认
        submit() {
            // console.log("打开匹配页")
            this.upload.open = false
            this.match.open = true
            if (this.uploadType == 0) {
                this.match.title = "卷内件导入"
            } else if (this.uploadType == 1) {
                this.match.title = "案卷导入"
            } else {
                this.match.title = "项目导入"
            }
            // this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
            //     this.$refs.matchRef.init(this.xlsTitle, this.sysTitle);     //获取子组件中init方法并将父组件数据传递给子组件
            // });
        },
        submitMatch(matchedData) {
            this.form = {
                categoryId: this.queryParams.categoryId,
                state: this.queryParams.state,
                jsType: this.queryParams.jsType,
                colNames: matchedData
            }
            if (this.subStr == "F") {
                this.form.type = this.uploadType
                // if (this.uploadType == 0) {
                //     this.form.type = this.uploadType
                //     this.form.folderId = "-1"
                // } else {
                //     this.form.type = this.uploadType
                // }
            } else if (this.subStr == "V") {
                if (this.uploadType == 0) {
                    this.form.type = 0
                    this.form.folderId = this.ids
                } else {
                    this.form.type = this.uploadType
                }
            } else {
                if (this.uploadType == 1) {
                    this.form.type = 1
                    this.form.itemId = this.ids
                } else {
                    this.form.type = this.uploadType
                }
            }
            const formData = new FormData();
            formData.append("file", this.file);
            formData.append("dataStr", JSON.stringify(this.form));
            uploadList(formData).then(response => {
                this.$modal.msgSuccess(response.msg);
                // this.match.open = false;
                this.getlistPost()
            })
            this.match.open = false;
        },
        matchCancelTap() {
            this.match.open = false;
        },
  }
}
</script>

<style scoped></style>
